﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using ASPNET.StarterKit.BusinessLogicLayer;
using ASPNET.StarterKit.DataAccessLayer;

public partial class InventoryTracker_InvoiceDetails : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        {
            txtDateTime.Text = System.DateTime.Now.ToString();
        }

        
    }
    protected void btnInvDetSubmit_Click(object sender, EventArgs e)
    {
        
        DataAccess DA = DataAccessHelper.GetDataAccess();
        InvoiceDetails aInvoice = new InvoiceDetails(ddrInvoiceItemName.SelectedItem.Text ,int.Parse( ddrInvoiceItemRate.SelectedValue),ddrInvDetTax.SelectedItem.Text,int.Parse( txtInvoiceTotalAmount.Text),DateTime.Parse(txtDateTime.Text),int.Parse( txtInvoiceItemQty.Text),int.Parse( txtInvoiceDiscount.Text));
        try
        {
            if (DA.CreateInvoiceDetails(aInvoice))
            {
                lblResult.Text = "Success";
            }
            else
            {
                lblResult.Text = "Failure";
            }
        }
        catch (Exception ex)
        {
            lblResult.Text = ex.Message.ToString();
        }





        
    //    Invoice aInv = new Invoice(ddrCustID1.SelectedIndex,ddrLocationID1.SelectedIndex,ddrTaxID1.SelectedIndex);
    //    try
    //    {
    //        if (DA.CreateInvoice(aInv))
    //        {
    //            lblResult.Text = "Success";
    //        }
    //        else
    //        {
    //            lblResult.Text = "Failure";
    //        }
    //    }
    //    catch (Exception ex)
    //    {
    //        lblResult.Text = ex.Message.ToString();
    //    }
        
    }



    protected void txtDateTime_TextChanged(object sender, EventArgs e)
    {
        
    }

    protected void txtAmount_TextChanged(object sender, EventArgs e)
    {
        int f = int.Parse(ddrInvoiceItemRate.SelectedValue);
        int q = int.Parse(txtInvoiceItemQty.Text);
        int Amt = (f * q);

        txtAmount.Text = Amt.ToString();
    }


    protected void btnInsert_Click(object sender, EventArgs e)
    {
        GridView1.Rows[1].Cells[1].Text = "Lokesh"; 
    }

   
}
